rowIndex = 3


var getRow = function (rowIndex) {
    let res = []
    res[1] = [1]
    let count = 2
    while (count <= rowIndex + 1) {
        res[count] = []
        for (let i = 0; i < count; i++) {
            if (i === 0 || i === count - 1) {
                res[count].push(1)
            } else {
                res[count].push(res[count - 1][i] + res[count - 1][i - 1])
            }
        }
        count++
    }
    return res[rowIndex + 1];
};
console.log(getRow(rowIndex));
